<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <!--体现申请列表-->
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								客户编号：<input type="text" name="merchantNo"/>
							</li>
							<li>
								申请状态：
								<select name="sTATUS" th:with="type=${@dict.getType('sys_withdraw_status')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>

							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">

				<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:moneyChange:export">-->
						<!--<i class="fa fa-download"></i> 导出-->
				 <!--</a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "system/moneyChange";
        //金额类型
		var datas = [[${@dict.getType('sys_money_type')}]];
		//提现状态
		var datas1 = [[${@dict.getType('sys_withdraw_status')}]];

        $(function() {
            var options = {
                url: prefix + "/applyMoneyList",

				exportUrl: prefix + "/export",
                modalName: "资金变动",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id',
					title : 'id',
					visible: false
				},
				{
					field : 'userId',
					title : '商户编号',
					sortable: true
				},
				{
					field : 'paymentOrderId',
					title : '提现名称',
					sortable: true,
					formatter: function(value, row, index) {
						if(row.userType=="10A"){
							return row.agentName
						}else{
							return row.merchantName
						}

					}
				},
				{
					field : 'moneyType',
					title : '金额类型',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas, value);
					}
				},
				{
					field : 'createTime',
					title : '创建时间',
					sortable: true
				},
				{
					field : 'trxAmt',
					title : '提现金额',
					sortable: true
				},
				{
					field : 'status',
					title : '申请状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas1, value);
					}
				},
					{
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push(statusTools(row));
							return actions.join('');
						}
					}
		       ]
            };
            $.table.init(options);
        });
		//通过审核  拒绝审核
		function statusTools(row) {
			var content=""
			 if(row.status == "10B"){
				 content+= '<a class="btn btn-success btn-xs '  + '" href="#" onclick="adopt(\'' + row.id + '\')">通过审核</a> ';
				 content+= '<a class="btn btn-danger btn-xs '  + '" href="#" onclick="refuse (\'' + row.id + '\')">拒绝审核</a> ';
				return content;
			}

		}
		//通过审核
		function adopt(id) {
			$.modal.confirm("确认审核通过？", function() {
				$.operate.post(prefix + "/auditMoneyChange", { "id": id ,}
				);
			})
		}
		//拒绝审核
		function refuse(id) {
			$.modal.confirm("确认拒绝审核？", function() {
				$.operate.post(prefix + "/auditMoneyChange", { "id": id }
				);
			})
		}
    </script>
</body>
</html>